package 消费者与生产者模式练习.Test02;

public class T2 implements Runnable {
    Num n;

    public T2(Num n) {
        this.n = n;
    }

    @Override
    public void run() {
        while (true){
            synchronized (n){
                if (n.i % 2 == 1){
                    try {
                        n.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(Thread.currentThread().getName() + "-------->" + n.i);
                n.i++;
                n.notify();
            }
        }
    }
}
